public class projectsext {

    private final Projects__c ocp;
        
    // The extension constructor initializes the private member variable acct by using the getRecord method from the standard controller. 
    
    public projectsext(ApexPages.StandardController stdController) {
        this.ocp= (Projects__c)stdController.getRecord();
    }
  
public PageReference save(){
  try{
    insert ocp;
    PageReference newocp= new PageReference('/'+ ocp.Id);
     newocp.setRedirect(true);
      return newocp;
      }
   catch (Exception ex) {
       ApexPages.addMessages(ex);
       system.debug(ex);
       return null;
      }
}
}